package com.dhcc.bpm.alarm.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.dhcc.bpm.alarm.entity.statistic.AlarmStatistic;
import com.dhcc.bpm.alarm.service.IAlarmRecordService;
import com.dhcc.bpm.alarm.service.IAlarmStatisticService;
import com.dhcc.bpm.alarm.vo.AlarmRecordVO;
import com.dhcc.bpm.alarm.vo.AlarmStatisticVO;
import com.dhcc.bpm.alarm.vo.statistics.AlarmJoinClassVO;
import com.dhcc.bpm.alarm.vo.statistics.AlarmStrategyTimeVO;
import com.dhcc.bpm.alarm.vo.statistics.StatisticsStrategyVO;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Description 告警统计控制器
 * @author caoyanlong
 * @date 20220223
 * 
 */
@RestController
@AllArgsConstructor
@NoArgsConstructor
@RequestMapping("alarm/alarmStatistic")
@Api(value = "预警策略表", tags = "接口")
public class AlarmStatisticController extends BladeController {
	
	@Autowired
    private IAlarmStatisticService alarmStatisticService;
	
	@Autowired
    private IAlarmRecordService alarmRecordService;
	
	/**
	 * @description 接入渠道,  策略数量,  预警数量
	 * @param alarmRecord
	 * @return
	 */
    @GetMapping("/classNum")
    @ApiOperationSupport(order = 1)
    @ApiOperation(value = "分类统计", notes = "传入AlarmStatistic")
    public R<List<AlarmStatisticVO>> classNum(AlarmStatistic alarmStatistic) {
    	List<AlarmStatisticVO> result = alarmStatisticService.classNum(alarmStatistic);
        return R.data(result);
    }
	
	/**
	 * @description 告警数量TOP5
	 * @param alarmRecord
	 * @return
	 */
    @GetMapping("/alarmNum")
    @ApiOperationSupport(order = 2)
    @ApiOperation(value = "告警数量统计", notes = "传入AlarmStatistic")
    public R<List<AlarmStatisticVO>> alarmNumber(AlarmStatistic alarmStatistic) {
    	List<AlarmStatisticVO> result = alarmStatisticService.alarmNumber(alarmStatistic);
        return R.data(result);
    }
    
    /**
     * @Description 告警通道分布
     * @Param 
     */
    @GetMapping("/alarmNoticeMethod")
    @ApiOperationSupport(order = 3)
    @ApiOperation(value = "告警通道统计", notes = "传入AlarmStatistic")
    public R<List<AlarmStatisticVO>> alarmNoticeMethod(AlarmStatistic alarmStatistic) {
    	List<AlarmStatisticVO> detail = alarmStatisticService.alarmNoticeMethod(alarmStatistic);
        return R.data(detail);
        
    }
    
    /**
     * @Description 系统维度预警
     * @Param 
     */
    @GetMapping("/alarmSystem")
    @ApiOperationSupport(order = 4)
    @ApiOperation(value = "系统维度预警", notes = "传入AlarmStatistic")
    public R<List<AlarmStatisticVO>> alarmSystem(AlarmStatistic alarmStatistic) {
    	List<AlarmStatisticVO> list = alarmStatisticService.alarmSystem(alarmStatistic);
        return R.data(list);
        
    }
    
    /**
     * @Description 告警对象状况
     * @Param 
     */
    @GetMapping("/alarmObj")
    @ApiOperationSupport(order = 5)
    @ApiOperation(value = "告警对象状况", notes = "传入AlarmStatistic")
    public R<List<AlarmStatisticVO>> alarmObj(AlarmStatistic request) {
    	List<AlarmStatisticVO> list = alarmStatisticService.alarmObj(request);
        return R.data(list);
    }
    
    /**
     * @Description 告警数量分布
     * @Param 
     */
    @GetMapping("/alarmNumGroup")
    @ApiOperationSupport(order = 6)
    @ApiOperation(value = "告警数量分布", notes = "传入AlarmStatistic")
    public R<List<AlarmStatisticVO>> alarmNumGroup(AlarmStatistic request) {
    	List<AlarmStatisticVO> list = alarmStatisticService.alarmNumGroup(request);
        return R.data(list);
        
    }
    
    /**
     * @Description 告警状态统计
     * @deprecated  已废弃，更换为最新预警查询接口
     * @Param 
     */
    @GetMapping("/alarmNumDays")
    @ApiOperationSupport(order = 7)
    @ApiOperation(value = "告警状态列表", notes = "传入AlarmStatistic")
    public R<List<AlarmStatisticVO>> alarmNumSts(AlarmStatistic request) {
    	List<AlarmStatisticVO> list = alarmStatisticService.alarmStsNum(request);
        return R.data(list);
        
    }
    
    /**
     * @param 最新的告警记录
     * @return
     */
    @GetMapping("/alarmRecordNewest")
    @ApiOperationSupport(order = 7)
    @ApiOperation(value = "告警状态列表", notes = "传入AlarmStatistic")
    public R<IPage<AlarmRecordVO>> alarmNewestRecord(AlarmRecordVO request, Query query) {
    	query.setDescs("ALARM_TIME");
    	IPage<AlarmRecordVO> page = alarmRecordService.selectAlarmRecordPage(Condition.getPage(query), request);
        return R.data(page);
        
    }
    
    /**
     * @Description 系统策略数量
     * @Param 
     */
    @GetMapping("/alarmStrategy")
    @ApiOperationSupport(order = 8)
    @ApiOperation(value = "系统策略数量", notes = "传入AlarmStatistic")
    public R<List<AlarmStatisticVO>> alarmStrategy(AlarmStatistic request) {
    	List<AlarmStatisticVO> list = alarmStatisticService.alarmStrategy(request);
        return R.data(list);
    }
    
    /**
     * @Description 紧急告警数量
     * @Param 
     */
    @GetMapping("/alarmUrgentNum")
    @ApiOperationSupport(order = 9)
    @ApiOperation(value = "紧急告警数量", notes = "传入AlarmStatistic")
    public R<List<AlarmStatisticVO>> alarmUrgentNum(AlarmStatistic alarmStatistic) {
    	List<AlarmStatisticVO> list = alarmStatisticService.alarmUrgentNum(alarmStatistic);
        return R.data(list);
    }
    
    
    /**
     * @Description 策略统计展示
     * @Param 
     */
    @GetMapping("/alarmStatisticByCode")
    @ApiOperationSupport(order = 10)
    @ApiOperation(value = "系统策略数量", notes = "传入AlarmStatistic")
    public R<List<StatisticsStrategyVO>> alarmStatisticByCode(AlarmStatistic alarmStatistic) {
    	
    	List<StatisticsStrategyVO> list = alarmStatisticService.alarmStrategyByCode(alarmStatistic);
        return R.data(list);
    }
    
    
    /**
     * @Description 告警策略统计图
     * @Param 
     */
    @GetMapping("/alarmStrategyTime")
    @ApiOperationSupport(order = 11)
    @ApiOperation(value = "系统策略数量", notes = "传入timeType:1-近24小时、2-近7日、3-30天、4--当年, strategyCode")
    public R<List<AlarmStrategyTimeVO>> alarmStrategyTime(AlarmStatistic alarmStatistic) {
    	List<AlarmStrategyTimeVO> list = alarmStatisticService.alarmStrategyTime(alarmStatistic);
        return R.data(list);
    }
    
    /**
     * @Description 关联系统列表
     * @Param 
     */
    @GetMapping("/alarmJoinStrategy")
    @ApiOperationSupport(order = 11)
    @ApiOperation(value = "系统策略数量", notes = " strategyCode/systemNo")
    public R<IPage<AlarmJoinClassVO>> alarmJoinStrategy(AlarmStatistic alarmStatistic, Query query) {
    	IPage<AlarmJoinClassVO> list = alarmStatisticService.alarmJoinStrategy(Condition.getPage(query), alarmStatistic);
        return R.data(list);
    }
    
    /**
     * @Description 关联策略列表
     * @Param 
     */
    @GetMapping("/alarmJoinMethod")
    @ApiOperationSupport(order = 11)
    @ApiOperation(value = "系统策略数量", notes = "strategyCode/systemNo")
    public R<IPage<AlarmJoinClassVO>> alarmJoinMethod(AlarmStatistic alarmStatistic, Query query) {
    	IPage<AlarmJoinClassVO> list = alarmStatisticService.alarmJoinMethod(Condition.getPage(query), alarmStatistic);
        return R.data(list);
    }
   
}